package com.cuit.qx.aop;

import com.cuit.qx.service.ScheduledLogService;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @Author: lcj
 * @Decsription: 定时器执行情况
 * @Create: 2021/2/5
 * @Modified By:
 */
@Aspect
@Component
public class ScheduledAspect {

    @Pointcut("@annotation(org.springframework.scheduling.annotation.Scheduled)")
    public void proxyAspect() {}

    @Resource
    private ScheduledLogService scheduledLogService;

    @Around("proxyAspect()")
    public Object doInvoke(ProceedingJoinPoint pjp) throws Throwable {
        Object result = pjp.proceed();
        // 获取方法名
        String methodName = pjp.getSignature().getName();
        //更新数据
        scheduledLogService.updateByTime(methodName);
        return result;
    }
}
